package com.it.test;

import com.it.service.UserService;
import com.it.service.UserServiceImpl;
import com.it.utils.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Client {
    public static void main(String[] args) {
//        UserService userService=new UserServiceImpl();
//        UserService userService = (UserService) BeanFactory.getSingleBean("userService");
//        ApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
        ClassPathXmlApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = ac.getBean("userService", UserService.class);
        userService.add();
        userService.update();
        ac.close();
        /*
        spring单例模式类型使用
        ClassPathXmlApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
        可主动调用close关闭销毁
        注意：多列模式类型不支持
         */
    }
}
